package cn.agiledata.bank.myspace.dao;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.SessionFactory;

import cn.agiledata.bank.common.dao.HqlPageListTemplate;
import cn.agiledata.bank.myspace.bean.PeerInnerAccountQueryBean;
import com.vnv.infrastructure.logic.IPBAppFactory;

public class PeerInnerAccountPageList extends HqlPageListTemplate {
	private PeerInnerAccountQueryBean bean;
	
	public PeerInnerAccountPageList(PeerInnerAccountQueryBean bean) {
		// TODO Auto-generated constructor stub
		this.setSessionFactory(
				(SessionFactory)IPBAppFactory.getObj("sessionFactory"));
		this.bean = bean;
	}

	public String getHql() {
		// TODO Auto-generated method stub
		//2007-12-04由zxj增加如下查询条件：and a.peerAccount.status='7' and (a.peerAccount.emStatus='7' or a.peerAccount.mobStatus='7')
		//只查出账户状态正常的并且email和手机至少有一个是状态正常的预设账户（系统可能存在状态正常但email和手机状态都不正常的垃圾数据，所以增加此条件）
		String hSql = " from PeerInnerAccount a where a.account.id=:accountId and a.peerAccount.status='7' and (a.peerAccount.emStatus='7' or a.peerAccount.mobStatus='7')";
		
		hSql += " order by a.updateTime desc, a.id desc";
		return hSql;
	}

	public String getPageRecord() {
		// TODO Auto-generated method stub
		return bean.getPageRecord();
	}

	public Map getParams() {
		// TODO Auto-generated method stub
		Map map = new HashMap();
		
		map.put("accountId", bean.getAccountId());
		
		return map;
	}

	public String getStartPage() {
		// TODO Auto-generated method stub
		return bean.getStartPage();
	}
}
